// Created: Dec 11, 2014
//
// Author: wjinwen.1988@gmail.com

#ifndef CHI_DIRECTORY_H
#define CHI_DIRECTORY_H

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <limits.h>

namespace chi {
#ifndef S_IRWXUGO
#define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
#endif

class Directory {
 public:
  const static int kMaxPathLength = 256;
  
  static bool Exists(const char* filename);
  static bool DeleteFile(const char* filename);
  static bool IsDirectory(const char* dirname);
  static bool DeleteDirectory(const char* dirname);
  static bool DeleteDirectoryRecursively(const char* directory,
                                         const bool delete_flag = false);
  static bool CreateDirectory(const char* dirname, const mode_t dir_mode = 0);
  static bool CreateFullPath(const char* fullpath,
                             const bool with_file = false,
                             const mode_t dir_mode = 0);
  static bool Rename(const char* srcfilename, const char* destfilename);
  static int64_t Size(const char* filename);
};

}  // namespace chi

#endif

